<?php

$fontSize = isset($_GET["FontSize"]) ? (int)$_GET["FontSize"] : 16;
$fontText = isset($_GET["SignatureText"]) ? $_GET["SignatureText"] : "TeSt TeXt";
$fontColor = isset($_GET["FontColor"]) ? (int)$_GET["FontColor"] : 0x0;

/*
// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('../img/'));

// Name the font to be used (note the lack of the .ttf extension)
$fontName = 'VLADIMIR';
*/
$fontName = '../img/VLADIMIR.TTF';

//mi prendo il bounding box
$bbox = imagettfbbox($fontSize, 0, $fontName, $fontText);

$width = $bbox[2]-$bbox[0];
$height = $bbox[1]-$bbox[5];

header("Content-type: image/png");
$img = imagecreate($width, $height*1.5);
imagecolorallocate($img, 255, 255, 255);
$textColor = imagecolorallocate($img, ($fontColor >> 16) & 0xFF, ($fontColor >> 8) & 0xFF, $fontColor & 0xFF);

imagettftext($img, $fontSize, 0, 0, $height, $textColor, $fontName, $fontText);
//imagettftext($img, $fontSize, 0, 1, $height+1, $textColor, $fontName, $fontText);

header("Content-type: image/png");
imagepng($img);
imagedestroy($img);

?>
